<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr" id="minwidth" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
    <body>
<script type="text/javascript">
RM = {};
RM.Pages = {};
RM.Pages.User = {};
RM.Pages.User.Unit = {};
RM.Common = {};

RM.BaseURL = '<?php echo RM_Environment::getInstance()->getRouter()->_(); ?>';
RM.RootURL = '<?php echo RM_Environment::getConnector()->getRootURL(); ?>';
<?php echo $this->_router->getAccembleURLJsCode(); ?>
</script>
<script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/admin/common.js"></script>
<!-- ExtJS Base -->
<?php
$config = Zend_Registry::get('config');
if ((int)$config->get('js')->get('debug')->get('user') == 1) {
?>
<script language="javascript" type='text/javascript' src='<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/adapter/ext/ext-base-debug.js'></script>
<script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/ext-all-debug.js"></script>
<?php
} else {
?>
<script language="javascript" type='text/javascript' src='<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/adapter/ext/ext-base.js'></script>
<script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/ext-all.js"></script>
<?php
}
?>

<!-- ExtJS CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/resources/css/ext-all.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/css/user.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/plugins/Hospitality/css/accompicker.css" />
<?php
$criteria = RM_Reservation_Manager::getInstance()->getCriteria();
if (!isset($criteria)){
    ?>
    <center><div id="RM_accommpicker_message"><?php echo $this->_translate->_('User.Hospitality.AccommPicker','error');?></div></center>
    <?php
    die();
}

$config = new RM_Config;
$priceSystem = RM_Prices_Manager::getInstance()->getRealPriceSystem($this->unit);
$peopleMaximums = $priceSystem->getPeopleMaximums($this->unit_id); // returns array containing "max_occupancy"=>$max_occupancy,"max_adults"=>$max_adults,"max_children"=>$max_children,"max_infants"=>$max_infants
$currencySymbol = $config->getValue('rm_config_currency_symbol');

?>
<div class="RM_accomm_modal_container">
    <div class="RM_accomm_modal_header">
            <?php echo $this->_translate->_('User.Hospitality.AccommPicker','Title');?>
    </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="15">
      <?php
      foreach($this->data as $selection){
      ?>
      <tr>
        <td><div class="RM_accomm_nametext"><?php echo $this->_translate->_('User.Hospitality.Main',$selection['name']);?></div></td>
        <td><div class="RM_accomm_pricetext"><?php echo $currencySymbol." ".$selection['price'];?></div></td>
        <td>
            <a href="javascript:void(0);" onclick="RM_Submit('<?php echo $selection['name'];?>')">
            <div class="RM_accomm_selecttext"><?php echo $this->_translate->_('User.Hospitality.AccommPicker','Select');?></div>
            <div class="RM_accomm_selectimage"><img src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/plugins/Hospitality/images/arrow.png" border="0" alt="" /></div>
            </a>
        </td>
      </tr>
      <?php
      }
      ?>
    </table>
    <center><div id="RM_accommpicker_message" style="display: none;"></div></center>
</div>

<script type="text/javascript">

function RM_Submit(boardtype){

    document.getElementById('RM_accommpicker_message').innerHTML = "<?php echo $this->_translate->_('User.Hospitality.AccommPicker','Saving');?>";
    document.getElementById('RM_accommpicker_message').style.display = "block";
    
    // save the board_type to the session for the calculator to use
    if (boardtype){
        var conn = new Ext.data.Connection();
        var request = {
            url: RM.Common.AssembleURL({
                controller : 'HospitalityPrices',
                action: 'setboardtypeJson'
            }),
            params: {
                unit_id : <?php echo $this->unit_id;?>,
                board_type: boardtype
            },
            method: 'POST',
            success: function(){
                window.parent.location.reload();
            },
            failure: function(){
                document.getElementById('RM_accommpicker_message').innerHTML = "<?php echo $this->_translate->_('User.DatePicker','AJAXFailure');?>";
            }
        };
        conn.request(request);
    }
}

</script>
</body>
</html>